/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年4月22日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.SaleorderitemDao;
import org.scauinfo.fpos.dao.impl.SaleorderitemDao;
import org.scauinfo.fpos.service.SaleorderitemService;
import org.scauinfo.fpos.vo.Saleorderitem;
import org.scauinfo.fpos.vo.Saleorderitem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 *
 */
@Service
public class SaleorderitemServiceImpl implements SaleorderitemService{

	@Autowired
	private SaleorderitemDao saleorderitemDao;

	@Override
	public void saveSaleorderitem(Saleorderitem saleorderitem) {
		saleorderitemDao.save(saleorderitem);
	}

	@Override
	public void updateSaleorderitem(Saleorderitem saleorderitem) {
		saleorderitemDao.update(saleorderitem);
	}

	@Override
	public void deleteSaleorderitem(int id) {
		Saleorderitem saleorderitem = saleorderitemDao.get(id);
		saleorderitem.setProduct(null);
		saleorderitem.setSaleorder(null);
		saleorderitemDao.delete(saleorderitem);
	}

	@Override
	public List<Saleorderitem> findAllSaleorderitem(int page, int rows,
			String sort, String order) {
		return saleorderitemDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return saleorderitemDao.countAll();
	}

	@Override
	public boolean isExist(String SaleorderitemId) {
		boolean flag = false;
		String hql = "from Saleorderitem as p where p.saleorderitemId="
				+ SaleorderitemId;
		if (saleorderitemDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public List<Saleorderitem> findAllSaleorderitem() {
		return saleorderitemDao.findAll();
	}

	@Override
	public Saleorderitem get(Serializable id) {
		return saleorderitemDao.get(id);
	}

}
